from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from collections import OrderedDict

#1,自定义分类页
class MyPageNumberPagination(PageNumberPagination):
    page_size = 10
    page_size_query_param = 'pagesize'
    max_page_size = 99

    def get_paginated_response(self, data):
        return Response(OrderedDict([
            ('page', self.page.number),
            ('pages', self.page.paginator.num_pages),
            ('lists', data)
        ]))